package com.novel.entiy;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.novel.entiy.vo.ChapterVO;
import com.novel.utils.BeanConverter;
import com.novel.utils.ConverterUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 章节表
 *
 * @author tanghao
 * @date 2022/4/24
 */
@ApiModel(value = "com-novel-entiy-Chapter")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "chapter")
public class Chapter implements BeanConverter<ChapterVO> {
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "")
    private Long id;

    /**
     * 文章id
     */
    @TableField(value = "novel_id")
    @ApiModelProperty(value = "文章id")
    private Long novelId;

    /**
     * 章节名称
     */
    @TableField(value = "chapter_name")
    @ApiModelProperty(value = "章节名称")
    private String chapterName;

    /**
     * 章节号
     */
    @TableField(value = "chapter_no")
    @ApiModelProperty(value = "章节号")
    private Integer chapterNo;

    /**
     * 章节字数
     */
    @TableField(value = "word_nums")
    @ApiModelProperty(value = "章节字数")
    private Long wordNums;

    /**
     * 章节内容-markdown
     */
    @TableField(value = "chapter_content_markdown")
    @ApiModelProperty(value = "章节内容-markdown")
    private String chapterContentMarkdown;

    /**
     * 章节内容-html
     */
    @TableField(value = "chapter_content_html")
    @ApiModelProperty(value = "章节内容-html")
    private String chapterContentHtml;

    /**
     * 0:草稿 1:发布
     */
    @TableField(value = "`status`")
    @ApiModelProperty(value = "0:草稿 1:发布")
    private Integer status;

    /**
     * 创建时间
     */
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @TableField(value = "created_time",fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    private Date createdTime;

    /**
     * 更新时间
     */
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @TableField(value = "updated_time",fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新时间")
    private Date updatedTime;

    /**
     * 发布时间
     */
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @TableField(value = "publish_time")
    @ApiModelProperty(value = "发布时间")
    private Date publishTime;

    public static final String COL_ID = "id";

    public static final String COL_NOVEL_ID = "novel_id";

    public static final String COL_CHAPTER_NAME = "chapter_name";

    public static final String COL_CHAPTER_NO = "chapter_no";

    public static final String COL_WORD_NUMS = "word_nums";

    public static final String COL_CHAPTER_CONTENT_MARKDOWN = "chapter_content_markdown";

    public static final String COL_CHAPTER_CONTENT_HTML = "chapter_content_html";

    public static final String COL_STATUS = "status";

    public static final String COL_CREATED_TIME = "created_time";

    public static final String COL_UPDATED_TIME = "updated_time";

    public static final String COL_PUBLISH_TIME = "publish_time";

    /**
     * 转换接口方法
     *
     * @return T
     */
    @Override
    public ChapterVO doForward() {
        ChapterVO chapterVO = new ChapterVO();
        ConverterUtil.copyPropertiesIgnoreNull(this, chapterVO);
        return chapterVO;
    }
}